package com.hugh.lagouserviceemail.comtroller.email.impl;

import com.hugh.lagouserviceemail.comtroller.email.EmailService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * @Author: Hugh
 * @Date: 2020/7/20
 */

@Service
@Slf4j
@RefreshScope
public class EmailServiceImpl implements EmailService {

    @Autowired
    private EmailUtil emailUtil;

    @Value("${email.title}")
    private String title;
    @Override
    public void sendEmail(String code, String email) {
        log.info("this is EmailService");
        String content = "The code is:";
        if(StringUtils.isEmpty(title)) {
            title = "login check code";
        }
        emailUtil.sendEmail(title, content + code, email);
    }
}
